#include <cstdio>

int main(int argc, char const *argv[]){
    int input_num;
    while (scanf("%d", &input_num) != EOF) {
        int size = 0, temp_num;
        int out_put[20];
        do {
            temp_num = input_num % 8;
            out_put[size++] = temp_num;
            input_num /= 8;
        } while (input_num != 0);
        for (int i = size - 1; i >= 0; i--)
            printf("%d", out_put[i]);
        printf("\n");
    }
    return 0;
}